package main

import (
	"fmt"
)

func main() {

	if 1 < 2 {
		fmt.Println("没意思")
	} else if 1 > 2 {
		fmt.Println("没意思")
	} else {
		fmt.Println("没意思")
	}

	//if语句允许有局部变量
	if num := 1; num > 0 {
		fmt.Println(num)
	}

	switch a := 1; a {
	case 1:
		fmt.Println(a)
		break
	default:
		fmt.Println(a + 1)
	}

	//支持布尔类型switch "fallthrough"执行后续case
	num := 1
	switch {
	case num > 0:
		fmt.Println(num)
		fallthrough
	case num > 1:
		fmt.Println(num + 1)
		break
	default:
		fmt.Println(num + 1)
	}

	for i := 0; i < 5; i++ {
		fmt.Print(num)
	}

	//while(condition)
	i := 1
	for i < 5 {
		fmt.Print(num)
		i++
	}
	fmt.Println()

	//for range 双变量值写法
	arr := [5]int{1, 2, 3, 4, 5}
	for index, value := range arr {
		fmt.Printf("index:%d value:%d\n", index, value)
	}
}
